/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package rg1homework2;

import java.util.Arrays;

/**
 *
 * @author apple
 */
public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        
         int[] factors=new int[(int)Math.sqrt(100000)];    
         int count=0;
         int sum=0;
         for(int num=2;num<=100000;num++)
         {
             for(int i=2;i<Math.sqrt(num);i++)
             {
                 if(num%i==0)
                 {
                     factors[count]=i;
                     sum=sum+i;
                     count++;
                     factors[count]=num/i;
                     sum=sum+num/i;
                     count++;
                 }
             }
             if(num==sum+1)
             {
                 System.out.println("PerfactNum is "+num);
                 Arrays.sort(factors, 0, count);
                 System.out.print("1, ");
                 for(int j=0;j<count;j++)
                 {
                     System.out.print(factors[j]+", ");
                 }
                 System.out.println();
             }
             Arrays.fill(factors,0);
             sum=0;
             count=0;
         }

        

    }
}
